local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerComponent(),"HomeButton_"..script.Name);
local HomeGui= ClientOHOH.load.UIManager().ui_list.HomeGui
-- 参加一场战斗后 开启

local gUnLockLevel=3


function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);

    self:HideButton()

	self.DataStore=self.parent:GetComponent(_G.ClientOHOH.load.Client_PlayerDataComponent())

    self.ConList={}
    local con= self.parent.LevelChangeEvent:Connect(function(level)
        self:UpdData(level,self.DataStore:GetData("base").rebirth)
	end)

    table.insert( self.ConList,con)

    self:UpdData(self.DataStore:GetData("base").level,self.DataStore:GetData("base").rebirth)

    
end;

function M.HideButton(self)
    HomeGui.insts.Gift.button.Parent.Visible=false
end

function M.ShowButton(self)
    HomeGui.insts.Gift.button.Parent.Visible=true
    self:dtor()
end

function M.UpdData(self,level,rebirth)
    if level>=gUnLockLevel then
        self:ShowButton()
    elseif  rebirth>0 then
        self:ShowButton()
    end
end


function M.dtor(self)
     for k,v in pairs(self.ConList) do
        v:Disconnect()
     end
     self.ConList={}
	M.super.dtor(self);
end;

return M